package com.sfy.login.vo;

import com.sfy.login.common.CommonString;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class R {
    private int code;
    private String msg;
    private Object data;

    //成功
    public static R ok(Object obj) {
        return new R(CommonString.R_OK, "OK", obj);
    }

    public static R ok() {
        return new R(CommonString.R_OK, "OK", null);
    }

    public static R ok(Integer code) {
        return new R(code, "OK", null);
    }

    //失败
    public static R fail(String msg) {
        return new R(CommonString.R_FAIL, msg, null);
    }

    public static R fail() {
        return new R(CommonString.R_FAIL, "FAIL", null);
    }

    public static R fail(Integer code) {
        return new R(code, "FAIL", null);
    }
}